﻿using System;
using System.Windows.Forms;

namespace CustomRoad.Controls
{
    public partial class Inclination : UserControl
    {
        #region Public Constructors

        public Inclination()
        {
            InitializeComponent();
            this.label_InclinationStart.Text = "0°";
            this.label_InclinationMiddle.Text = "0°";
            this.label_InclinationEnd.Text = "0°";
        }

        #endregion Public Constructors

        #region Public Events

        public event EventHandler InclinationEndChanged;

        public event EventHandler InclinationMiddleChanged;

        public event EventHandler InclinationStartChanged;

        #endregion Public Events

        #region Public Properties

        public int InclinationEnd
        {
            get { return this.trackBar_InclinationEnd.Value; }
            set { this.trackBar_InclinationEnd.Value = value; }
        }

        public int InclinationMiddle
        {
            get { return this.trackBar_InclinationMiddle.Value; }
            set { this.trackBar_InclinationMiddle.Value = value; }
        }

        public int InclinationStart
        {
            get { return this.trackBar_InclinationStart.Value; }
            set { this.trackBar_InclinationStart.Value = value; }
        }

        #endregion Public Properties

        #region Private Methods

        private void trackBar_InclinationEnd_Scroll(object sender, EventArgs e)
        {
            this.label_InclinationEnd.Text = (this.trackBar_InclinationEnd.Value).ToString() + "°";

            if (this.InclinationEndChanged != null)
                this.InclinationEndChanged(this.trackBar_InclinationEnd.Value, null);
        }

        private void trackBar_inclinationMiddle_Scroll(object sender, EventArgs e)
        {
            this.label_InclinationMiddle.Text = (this.trackBar_InclinationMiddle.Value).ToString() + "°";

            if (this.InclinationMiddleChanged != null)
                this.InclinationMiddleChanged(this.trackBar_InclinationMiddle.Value, null);
        }

        private void trackBar_InclinationStart_Scroll(object sender, EventArgs e)
        {
            this.label_InclinationStart.Text = (this.trackBar_InclinationStart.Value).ToString() + "°";

            if (this.InclinationStartChanged != null)
                this.InclinationStartChanged(this.trackBar_InclinationStart.Value, null);
        }

        private void trackBar_RightMB_Reset(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                TrackBar trackbar = sender as TrackBar;
                trackbar.Value = 0;
            }
        }

        #endregion Private Methods
    }
}